#include <stdio.h>
#include <stdlib.h>

void sort_decs()
{
    int frequency = 0;
    int arr[10] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
#if 0
    do
    {
        int intputValue;
        printf("请输入第%d个元素\n", frequency + 1);
        scanf("%d", &intputValue);
        arr[frequency] = intputValue;
        frequency++;
    } while (frequency < 10);
#endif

    int begin = 0;
    int end = sizeof(arr) / sizeof(int) - 1;
    do
    {
        int a = arr[begin];
        int b = arr[end];
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        arr[begin] = a;
        arr[end] = b;
        begin++;
        end--;
    } while (begin < end);

    for (int i = 0; i < sizeof(arr) / sizeof(int); i++)
    {
        printf("%d ", arr[i]);
    }
}

int get_max_value(int *arr, int arr_length)
{
    int index = 0;
    int max_value = 0;
    int result_index = 0;
    do
    {
        if (arr[index] > max_value)
        {
            max_value = arr[index];
            result_index = index;
        }
        index++;
    } while (index < arr_length);
    return result_index;
}

int get_max_index(int *arr, int arr_length)
{
    int index = 0;
    int max_value = 0;
    do
    {
        max_value = arr[index] > max_value ? arr[index] : max_value;
        index++;
    } while (index < arr_length);
    return index;
}

void input_arr()
{
    int arr[10] = {5, 4, 3, 2, 1, 10, 9, 8, 7, 6};
    int frequency = 0;

#if 0 
    do
    {
        int input;
        scanf("%d", &input);
        arr[frequency] = input;
    } while (frequency < 10);
#endif
    int resultIndex = get_max_index(arr, sizeof(arr) / sizeof(int));
    int resultValue = get_max_value(arr, sizeof(arr) / sizeof(int));
    printf("resultValue = %d, resultIndex = %d\n", resultValue, resultIndex);
}

int main(int argc, char const *argv[])
{
#if 0 
    sort_decs();
#endif

#if 1
    input_arr();
#endif
    /* code */
    return 0;
}
